package com.web.common.document.api;

import java.util.List;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.web.common.api.config.ServiceInstanceName;
import com.web.common.document.entity.DocumentContent;
import com.web.common.document.entity.ShareDocInfo;
import com.web.common.result.R;

@FeignClient(name = ServiceInstanceName.SERVICE_DOCUMENT_NAME, contextId = "documentShareApi", path = "/doc/share")
public interface DocumentShareApi {

	/**
	 * 根据分享码获取文档信息
	 * @param shareCode 分享码
	 * @return 文档内容及目录
	 *
	 * @author zhouhui
	 * @since 2023.12.19 
	 */
	@GetMapping(path = "/{shareCode}")
	@ResponseBody
	R<ShareDocInfo> shareDocToAllUser(@PathVariable("shareCode") String shareCode);
	
	/**
	 * 根据分享码和索引获取章节内容
	 * @param shareCode 分享码
	 * @param index 章节的索引
	 * @return DocumentContent 章节信息
	 *
	 * @author zhouhui
	 * @since 2023.12.19 
	 */
	@PostMapping(path = "/content/{shareCode}")
	@ResponseBody
	R<DocumentContent> shareDocContent(@PathVariable("shareCode") String shareCode, @RequestParam("index") String index);
	
	
	/**
	 * 查询文档内容
	 * @param shareCode 分享码
	 * @param content 查询内容
	 * @return List<DocumentContent> 查询到的文档内容
	 *
	 * @author zhouhui
	 * @since 2024.02.13
	 */
	@PostMapping(path = "/content/search/{shareCode}")
	@ResponseBody
	R<List<DocumentContent>> searchDocContent(@PathVariable("shareCode") String shareCode, @RequestParam("content") String content);
}
